home *** CD-ROM | disk | FTP | other *** search
/ Adobe Digital Video Collection / Digital Video Collection CD.iso / IlIustrator 10 / data1.cab / Program_Files / Presets / Scripts / ChangeSizesOfTextSelection.js < prev    next >
Encoding:
Text File  |  2001-10-30  |  1.3 KB  |  60 lines

  1. // change size of paragraph text
  2.  
  3. //$.bp();
  4.  
  5. ChangeSize();
  6.  
  7. function ChangeSize()
  8. {
  9.     selectedItems = selection;
  10.     // check to make sure something is selected.
  11.     if (selectedItems.length == 0)
  12.     {
  13.         alert("Nothing is selected");
  14.         return;
  15.     }
  16.  
  17.     endIndex = selectedItems.length;
  18.  
  19.     for (index = 0; index < endIndex; index++)
  20.     {
  21.         pageObject = selectedItems[index];
  22.         pageItemType = pageObject.typename;
  23.  
  24.         if (pageItemType == "TextArtItem")
  25.         {
  26.             // get the paragraphs from the selection.
  27.             theTextRange = pageObject.textRange();
  28.             paraTextRange = theTextRange.paragraphs;
  29.             numParagraphs = paraTextRange.length;
  30.  
  31.             for (i = 0 ; i < numParagraphs ; i++)
  32.             {
  33.                 aParagraph = paraTextRange[i];
  34.  
  35.                 charTextRange = aParagraph.characters;
  36.                 charCount = charTextRange.length;
  37.  
  38.                 if (charCount > 1)
  39.                 {
  40.                     halfWay = Math.round(charCount/2);
  41.                     fontSizeChanger = 36/halfWay;
  42.                     currentFontSize = 48;
  43.                     for (j = 0 ; j < halfWay-1; j++)
  44.                     {
  45.                         theChar = charTextRange[j];
  46.                         theChar.size = currentFontSize;    
  47.                         currentFontSize = currentFontSize - fontSizeChanger;
  48.                     }
  49.                     
  50.                     for (j = halfWay; j < charCount ; j++)
  51.                     {
  52.                         theChar = charTextRange[j];
  53.                         theChar.size = currentFontSize;
  54.                         currentFontSize = currentFontSize + fontSizeChanger;
  55.                     }
  56.                 }
  57.             }
  58.         }
  59.     }
  60. }